<template>
	<view class="container u-skeleton">
		<view v-if="scenicList&&scenicList.length"  class="down-box">
			<view   class="scenic-list">
				<view @click="goScenicDetail(item.id)" class="item" v-for="(item,index) in scenicList" :key="index">
					<view class="left-box u-skeleton-fillet">
						<image :src="item.image" ></image>
					</view>
					<view class="right-box">
						<view class="u-skeleton-rect name display-flex" style="margin-top: 6px;">
							{{item.scenic_name}}
							<view class="grade" v-if="item.grade">
								{{item.grade}}A
							</view>
						</view>
						<view class="u-skeleton-rect row display-flex loc">
							<view class="" style="margin-right: 6px;">
								{{item.short_address_name?item.short_address_name:"未知"}}
							</view>
							<view class="">
								距您{{item.distance}}km
							</view>
						</view>
						<view v-if="item.price" class="u-skeleton-rect row display-flex">
							<view class="">
								<text style="color: #ff6248;font-size: 8px;">￥</text>
								<text style="color: #ff6248;font-size: 16px;font-weight: 600;">{{item.price}}</text>起
							</view>
						</view>
						<view class="u-skeleton-rect row display-flex" style="margin: 5px 0">
							<view class="" style="font-weight: 600;color: #000000;">
								特色
							</view>
							<view class="" style="width: 200px;">
								 <view class="text-ellipsis">
								 	• {{item.trait?item.trait:'未知'}}
								 </view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<emptyPage v-else title="暂无景点门票"></emptyPage>
		
		<u-skeleton :loading="skeleton" :animation="true" bgColor="#FFF"></u-skeleton>
		<u-no-network></u-no-network>
	</view>
</template>

<script>
import emptyPage from '@/components/emptyPage.vue'

import {searchScenic} from '@/api/scenic'
export default {
	components:{
		emptyPage
	},
	data() {
		return {
			skeleton:true,
			scenicList:[{},{},{},{},{}],
		};
	},
	onShow() {


	},
	onReady() {

	},
	onLoad() {
		uni.getLocation({
			type: 'wgs84',
			success: function(res) {
				try {
					uni.setStorageSync('user_latitude', res.latitude);
					uni.setStorageSync('user_longitude', res.longitude);
				} catch {}
			}
		});
		this.getList()
	},
	methods: {
		getList(){
			let lng = uni.getStorageSync('user_longitude'),lat=uni.getStorageSync('user_latitude')
			searchScenic({lng:lng, lat:lat}).then(res =>{
				this.skeleton = false
				this.scenicList= res.data.list
			})
		},
		goScenicDetail(id){
			uni.navigateTo({
				url:"/pages/scenic/scenic_detail?id="+id
			})
		}
	
	}
};
</script>

<style>
page{
	background-color: #FFFFFF;
}
.down-box {
    flex: auto;
    overflow-y: auto;
	padding-bottom: 30px;
}
.scenic-list{
	background-color: #FFFFFF;
}
.item{
	padding: 10px;
	border-bottom: 1px solid #f0f0f0;
	display: flex;
}
.left-box{
	width: 100px;
	height: 100px;
	border-radius: 4px;
	margin-right: 8px;
	position: relative;
	overflow: hidden;
}
.left-box image {
	width: 100%;
	height: 100%;
}
.right-box{
	flex: 1;
	overflow: hidden;
}
.right-box .name{
	font-weight: 600;
	font-size: 14px;
	color: #333;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	height: 15px;
	line-height: 15px;
}
.right-box .name .grade{
	 border-radius: 2px;
	color: #fff;
	font-weight: 700;
	background: linear-gradient(-90deg,#cf7632,#f8b891);
	width: 20px;
	line-height: 15px;
	height: 15px;
	text-align: center;
	font-size: 10px;
	margin-left: 4px;
	padding: 0 2px;
	align-items: center;
	justify-content: center;
}
.row{
	display: flex;
	align-items: flex-end;
	margin-bottom: 4px;
}
.loc {
	margin-top: 6px;
	color: #5b5b5b;
}
</style>
